package cn.edu.scau.cmi.chenruilin.multipattern;
import java.util.ArrayList;
import java.util.List;

public class Marshal {
	private static final int maxnum = 10;
	private static int currentnum = 0;
	public static List<Marshal> marshalList = new ArrayList(maxnum); 
	public static ArrayList nameList = new ArrayList(maxnum); 
	private String name;
	public Marshal(String name) {
		nameList.add(name);
		this.name = name;
	}
	public void setCurrentNum() {
		this.currentnum = 0;
	}
	public static List<Marshal> getInstance(String name) {
		if(!nameList.contains(name) && name != null && currentnum < maxnum) {
			Marshal marshal = new Marshal(name);
			marshalList.add(marshal);
			currentnum++;
		}
		return marshalList;
	}
	public String toString() {
		return name + getClass().getName() + '@' + Integer.toHexString(hashCode());
	}
	public static void reset(){
		marshalList.clear();
		nameList.clear();
		currentnum = 0;
	}
	
	
}